//
//  MeSetInfoCell.m
//  Ginix
//
//  Created by fzq on 2025/2/17.
//

#import "MeSetInfoCell.h"

@interface MeSetInfoCell()
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UIButton * headBtn;
@property (nonatomic,strong) UIImageView * arrow;
@property (nonatomic,strong) UITextField * infoField;
@end

@implementation MeSetInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15 * FMScaleX);
        make.centerY.equalTo(@0);
    }];
    [self addSubview:self.arrow];
    [_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15 * FMScaleX);
        make.centerY.equalTo(@0);
    }];
    [self addSubview:self.infoField];
    [_infoField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrow.mas_left).offset(-10* FMScaleX);
        make.centerY.equalTo(@0);
    }];
    [self addSubview:self.headBtn];
    [_headBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrow.mas_left).offset(-10* FMScaleX);
        make.centerY.equalTo(@0);
        make.size.mas_offset(CGSizeMake(40  * FMScaleX, 40 * FMScaleX));
    }];
}

-(void)setIndex:(NSInteger)index{
    
    switch (index) {
        case 0:
            self.nameLabel.text = @"头像";
            self.headBtn.hidden = NO;
            self.arrow.hidden = NO;
            [self.headBtn sd_setImageWithURL:[NSURL URLWithString:UserInfoModel.shareInstance.userModel.avatar] forState:UIControlStateNormal];
            break;
        case 1:
            self.nameLabel.text = @"用户名称";
            self.infoField.hidden = NO;
            self.headBtn.hidden = YES;
            self.infoField.text = UserInfoModel.shareInstance.userModel.nickName;
            break;
        case 2:
            self.nameLabel.text = @"绑定手机";
            self.infoField.hidden = NO;
            self.infoField.text = UserInfoModel.shareInstance.userModel.phone;

            break;
        case 3:
            self.nameLabel.text = @"性别";
            self.arrow.hidden = NO;
            self.infoField.hidden = NO;
            self.infoField.text = UserInfoModel.shareInstance.userModel.sex == 1 ? @"男":@"女";

            break;
        case 4:
            self.nameLabel.text = @"生日";
            self.arrow.hidden = NO;
            self.infoField.hidden = NO;
            self.infoField.text = UserInfoModel.shareInstance.userModel.birthday;

            break;
        case 5:
            self.nameLabel.text = @"身高";
            self.arrow.hidden = NO;
            self.infoField.hidden = NO;
            self.infoField.text = [NSString stringWithFormat:@"%@CM",UserInfoModel.shareInstance.userModel.height];

            break;
        case 6:
            self.nameLabel.text = @"体重";
            self.arrow.hidden = NO;
            self.infoField.hidden = NO;
            self.infoField.text = [NSString stringWithFormat:@"%@KG",UserInfoModel.shareInstance.userModel.weight];

            break;
        default:
            break;
    }
    
}


-(UILabel *)nameLabel{
    
    if(!_nameLabel){
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Regular(17);
        _nameLabel.textColor = RDRGB(0x666666);
    }
    return _nameLabel;
}
-(UIImageView *)arrow{
    
    if(!_arrow){
        _arrow = [[UIImageView alloc]init];
        _arrow.image = [UIImage imageNamed:@"Me_set_arrow"];
        _arrow.hidden = YES;
    }
    return _arrow;
}
-(UIButton *)headBtn{
    
    if(!_headBtn){
        _headBtn = [[UIButton alloc]init];
        [_headBtn setCornerRadius:20 * FMScaleX];
        [_headBtn setImage:[UIImage imageNamed:@"Me_set_head"] forState:UIControlStateNormal];
        _headBtn.hidden = YES;
    }
    return _headBtn;
}

-(UITextField *)infoField{
    
    if(!_infoField){
        _infoField = [[UITextField alloc]init];
        _infoField.textColor = RDRGB(0x333333);
        _infoField.font = Regular(17);
        _infoField.textAlignment = NSTextAlignmentRight;
        _infoField.hidden = YES;
        _infoField.text = @"hahah";
    }
    return _infoField;
}
@end
